package com.api.hg.action;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.hg.BaseUtle;
import com.api.hg.DoorUtil;
import com.api.sw.duban.util.LogTool;
import com.engine.common.util.ParamUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

public class DoorAaction {
    private final static LogTool log = new LogTool("/log/assetlog/luolf/DoorAaction",false);
    public final static String zshgsub="5";//中山海关
    public final static String jsjsub="29";//缉私局
    public Map<String, Object> getDoorData(HttpServletRequest var1, HttpServletResponse var2){
        JSONArray datasMenu=new JSONArray();//菜单
        boolean button=true;
        Map<String, Object> apidatas = new HashMap<String, Object>();//数据
        JSONObject json=null;
        String frist="";
        String url="";
        Map<String,Object> params = ParamUtil.request2Map(var1);
        String bmid = (String) params.get("bmid");
        String ksid = (String) params.get("ksid");
        boolean isKjcld = false;//是否科技处领导
        boolean isSysadmin = false;
        boolean isZsadmin = false;
        try {
            User user = HrmUserVarify.getUser(var1, var2);
            int userid = user.getUID();
            if(BaseUtle.ckeckRole(userid+"",BaseUtle.sysadmin+"")) isSysadmin = true;
            if(BaseUtle.ckeckRole(userid+"",BaseUtle.zssysadmin+"")) isZsadmin = true;
            //1全关 2分部 3科室 4个人
            //判断当前用户的属性  全关 还是 分部 还是科室 还是 个人
            if(BaseUtle.ckeckRole(userid+"",BaseUtle.sysadmin+","+BaseUtle.zssysadmin)){
                json=new JSONObject();
                //frist="1";
                //url="1";
                frist="4";
                url="4";
                json.put("key","1");
                json.put("selected",false);
                json.put("showname","系统管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","2");
                json.put("selected",false);
                json.put("showname","部门管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","3");
                json.put("selected",false);
                json.put("showname","科室管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","4");
                json.put("selected",true);
                json.put("showname","个人用户");
                datasMenu.add(json);
            }else if(BaseUtle.ckeckRole(userid+"",BaseUtle.subsysadmin+"")){
                //frist="2";
                // url="2";
                frist="4";
                url="4";
                json=new JSONObject();
                json.put("key","2");
                json.put("selected",false);
                json.put("showname","部门管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","3");
                json.put("selected",false);
                json.put("showname","科室管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","4");
                json.put("selected",true);
                json.put("showname","个人用户");
                datasMenu.add(json);
            }else if(BaseUtle.ckeckRole(userid+"",BaseUtle.bmsysadmin+"")){
                //frist="3";
                // url="3";
                frist="4";
                url="4";
                json=new JSONObject();
                json.put("key","3");
                json.put("selected",false);
                json.put("showname","科室管理员");
                datasMenu.add(json);
                json=new JSONObject();
                json.put("key","4");
                json.put("selected",true);
                json.put("showname","个人用户");
                datasMenu.add(json);
            }else{
                int js=checkRole(user);
                frist="4";
                url="4";
                json=new JSONObject();
                /*
                if(js==-1){
                    json.put("showname","个人用户");
                    json.put("key","4");
                    json.put("selected",true);
                    datasMenu.add(json);
                }else if(js==0){
                    //要针对部门领导增加一个切换的选项
                    json.put("showname","部门领导");
                    json.put("key","2");
                    json.put("selected",true);
                    url="2";
                    button=false;//这个不能改
                    frist="2";
                    datasMenu.add(json);
                }else if(js==1){
                    json.put("showname","关领导");
                    button=false;
                    json.put("key","1");
                    json.put("selected",true);
                    frist="1";
                    url="6";
                    datasMenu.add(json);
                }
                 */
                if(js==-1){
                    json.put("showname","个人用户");
                    json.put("key","4");
                    json.put("selected",true);
                    datasMenu.add(json);
                }
                if(js==0){

                    //要针对部门领导增加一个切换的选项
                    json.put("showname","部门领导");
                    json.put("key","2");
                    json.put("selected",true);
                    url="2";
                    button=false;//这个不能改
                    frist="2";
                    datasMenu.add(json);

                    log.writeLog(user.getUserDepartment()+"  "+user.getUserSubCompany1()+""+(ksid.equals(user.getUserDepartment()+"") && bmid.equals(user.getUserSubCompany1()+"")));
                    //当前用户在科技处处领导里并且不是系统管理员和中山管理员
                    if(ksid.equals(user.getUserDepartment()+"") && bmid.equals(user.getUserSubCompany1()+"") && !BaseUtle.ckeckRole(userid+"",BaseUtle.sysadmin+","+BaseUtle.zssysadmin)){
                        isKjcld = true;
                        json = new JSONObject();
                        json.put("showname","科技处领导");
                        json.put("selected",false);
                        json.put("key","5");
                        datasMenu.add(json);
                    }
                    //给予个人用户
                    json=new JSONObject();
                    json.put("showname","个人用户");
                    json.put("key","4");
                    json.put("selected",false);
                    datasMenu.add(json);
                }else if(js==1){
                    json.put("showname","关领导");
                    button=false;
                    json.put("key","1");
                    json.put("selected",true);
                    frist="1";
                    url="1";
                    datasMenu.add(json);
                    //给予个人用户
                    //2021年7月13日新增意见  关领导不显示个人用户
                    /*
                    json=new JSONObject();
                    json.put("showname","个人用户");
                    json.put("key","4");
                    json.put("selected",false);
                    datasMenu.add(json);
                    */
                }
            }
            //huangwm 增加用于判断你是否是中山海关管理员以及科技处领导
            if(BaseUtle.ckeckRole(userid+"",BaseUtle.zssysadmin+"")){
                apidatas.put("zsadmin",true);
            }else{
                apidatas.put("zsadmin",false);
            }

            apidatas.put("isSysadmin", isSysadmin);
            apidatas.put("isZsadmin", isZsadmin);
            apidatas.put("isKjcld", isKjcld);
            apidatas.put("frist",frist);
            apidatas.put("url",url);
            apidatas.put("button",button);
            apidatas.put("datasMenu",datasMenu);
        }catch(Exception e){
            log.writeLog("getDoorData Exception "+e.getMessage());
        }
            return apidatas;
    }
    /*
        加载视图数据
     */
   public Map<String, Object> getMenuData(HttpServletRequest var1, HttpServletResponse var2){
       JSONArray datasMenu=new JSONArray();//菜单
       DoorUtil doorUtil=new DoorUtil();
       Map<String, Object> apidatas = new HashMap<String, Object>();//数据

       JSONObject json=null;
       JSONArray JSONS=null;
       JSONObject subContent=null;
       String frist="";
       JSONObject itemJson=new JSONObject();

       try {
           User user = HrmUserVarify.getUser(var1, var2);
           int userid = user.getUID();
           boolean isKjcld = false;
           if("56".equals(user.getUserDepartment()+"") && "31".equals(user.getUserSubCompany1()+"")){
               isKjcld = true;
           }
           String lx=var1.getParameter("st");//视图类型
           log.writeLog("当前用户id "+userid+"; 当前视图类型 "+lx);
           if("1".equals(lx) ){//全关
           //if("1".equals(lx) || "5".equals(lx)){//全关
               //关领导  显示不同的视图
               //int js=checkRole(user);//1 关领导
               log.writeLog("判断是否为关领导或系统管理员 "+(!BaseUtle.ckeckRole(userid+"",BaseUtle.sysadmin+","+BaseUtle.zssysadmin)));
               log.writeLog("判断是否为中山海关或缉私局管理员 "+("1".equals(checkRole(user))));
               if(!BaseUtle.ckeckRole(userid+"",BaseUtle.sysadmin+","+BaseUtle.zssysadmin) && "1".equals(checkRole(user)+"")){
                   //关领导
                   json=new JSONObject();
                   json.put("name","全关设备");
                   json.put("icon","llficonfont swicongudingzichanshebeigouzhishenqingbiao");
                   json.put("iconBg","iconBox_01");
                   json.put("numberColor","#4D98FF");
                   json.put("lx",lx);

                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","总数");
                   subContent.put("count",doorUtil.getZgCount_gld());
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);
                   //设置 item itemJson
                   itemJson.put("rolesid", "admin");
                   itemJson.put("itemqg", doorUtil.getZgCount_gld());
                   itemJson.put("itemhg", doorUtil.getHgCount_gld());
                   itemJson.put("itemfhg", doorUtil.getFhgCount_gld());
                   itemJson.put("itemzk", doorUtil.getZkCount_gld());
                   itemJson.put("itemtsj", doorUtil.getTsjCount_gld());
                   itemJson.put("itembxsjsj", doorUtil.getBxsjsjCount_gld());
                   itemJson.put("itemdyj", doorUtil.getDyjCount_gld());
                   json.put("itemjson", itemJson);

                   json=new JSONObject();
                   json.put("name","资产总值");
                   json.put("icon","llficonfont swiconzongzhi ");
                   json.put("iconBg","iconBox_03");
                   json.put("numberColor","#FF8184");
                   json.put("lx",9);
                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","总值");
                   subContent.put("count",doorUtil.getAssetZz_gld());
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);

                   json=new JSONObject();
                   json.put("name","海关设备数量");
                   json.put("icon","llficonfont swiconhaiguan ");
                   json.put("iconBg","iconBox_04");
                   json.put("numberColor","#68C56A");
                   json.put("lx",10);
                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","总数");
                   subContent.put("count",doorUtil.getCountBylx(user,"0"));
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);

                   json=new JSONObject();
                   json.put("name","事业单位设备数量");
                   json.put("icon","llficonfont swiconshiyedanwei ");
                   json.put("iconBg","iconBox_02");
                   json.put("numberColor","#6665FF");
                   json.put("lx",10);
                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","总数");
                   subContent.put("count",doorUtil.getCountBylx(user,"1"));
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);

               }else {
                   json = new JSONObject();
                   json.put("name", "全关设备");
                   json.put("icon", "llficonfont swicongudingzichanshebeigouzhishenqingbiao");
                   json.put("iconBg", "iconBox_01");
                   json.put("numberColor", "#4D98FF");
                   json.put("lx", lx);

                   JSONS = new JSONArray();
                   subContent = new JSONObject();
                   subContent.put("name", "总数");
                   subContent.put("count", doorUtil.getZgCount(0 + "", user));
                   JSONS.add(subContent);
                   json.put("subContent", JSONS);
                   datasMenu.add(json);
                   //设置 item itemJson
                   itemJson.put("rolesid", "admin");
                   itemJson.put("itemqg", doorUtil.getZgCountWhere(0 + "", user));
                   itemJson.put("itemhg", doorUtil.getHgount(0 + "", user));
                   itemJson.put("itemfhg", doorUtil.getFhgount(0 + "", user));
                   itemJson.put("itemzk", doorUtil.getZk(0 + "", user));
                   itemJson.put("itemtsj", doorUtil.getTsjCount(0 + "", user));
                   itemJson.put("itembxsjsj", doorUtil.getBxsjsjCount(0 + "", user));
                   itemJson.put("itemdyj", doorUtil.getDyjCount(0 + "", user));
                   json.put("itemjson", itemJson);

                   json = new JSONObject();
                   json.put("name", "在库");
                   json.put("icon", "llficonfont swiconzaiku");
                   json.put("iconBg", "iconBox_02");
                   json.put("numberColor", "#6665FF");
                   json.put("lx", 2);

                   JSONS = new JSONArray();
                   subContent = new JSONObject();
                   subContent.put("name", "数量");
                   subContent.put("count", doorUtil.getZk(0 + "", user));
                   JSONS.add(subContent);
                   json.put("subContent", JSONS);
                   datasMenu.add(json);

                   json = new JSONObject();
                   json.put("name", "在用");
                   json.put("icon", "llficonfont swiconzaiyong1");
                   json.put("iconBg", "iconBox_03");
                   json.put("numberColor", "#FF8184");
                   json.put("lx", 3);
                   JSONS = new JSONArray();
                   subContent = new JSONObject();
                   subContent.put("name", "数量");
                   subContent.put("count", doorUtil.getZy(0 + "", user));
                   JSONS.add(subContent);
                   json.put("subContent", JSONS);
                   datasMenu.add(json);

                   json = new JSONObject();
                   json.put("name", "借用");
                   json.put("icon", "llficonfont swiconjieyong1");
                   json.put("iconBg", "iconBox_04");
                   json.put("numberColor", "#68C56A");
                   json.put("lx", 4);
                   JSONS = new JSONArray();
                   subContent = new JSONObject();
                   subContent.put("name", "数量");
                   subContent.put("count", doorUtil.getJy(0 + "", user));
                   JSONS.add(subContent);
                   json.put("subContent", JSONS);
                   datasMenu.add(json);
                   /*
                   json=new JSONObject();
                   json.put("name","报废中");
                   json.put("icon","llficonfont swiconbaofei");
                   json.put("iconBg","iconBox_04");
                   json.put("numberColor","#68C56A");
                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","数量");
                   subContent.put("count",doorUtil.getBfZ(0+"",user));
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);
                   */
                   json = new JSONObject();
                   String qgbfl = doorUtil.getAllBsBflV2(user);
                   //double bmbfl = doorUtil.getAllBsBflV2(user);
                   json.put("name", "账实不符率");
                   json.put("icon", "llficonfont swiconshiliangzhinengduixiang");
                   json.put("iconBg", "iconBox_02");
                   json.put("lx", 5);
                   json.put("numberColor", Double.parseDouble(qgbfl) > 0.00 ? "red" : "green");
                   //json.put("numberColor", bmbfl> 0.00 ? "red" : "green");
                   JSONS = new JSONArray();
                   subContent = new JSONObject();
                   subContent.put("name", "不符率");
                   subContent.put("count", Math.abs(Double.parseDouble(qgbfl)) + "%");
                   //subContent.put("count", Math.abs(bmbfl) + "%");
                   JSONS.add(subContent);
                   json.put("subContent", JSONS);
                   datasMenu.add(json);
               }
           }
           if("2".equals(lx)){//部门
               json=new JSONObject();
               json.put("name","部门设备");
               json.put("icon","llficonfont swicongudingzichanshebeigouzhishenqingbiao");
               json.put("iconBg","iconBox_01");
               json.put("numberColor","#4D98FF");
               json.put("lx",6);

               JSONS = new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getZgCount(1+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);
               //设置 item itemJson
               itemJson.put("rolesid", "bmgly");
               itemJson.put("itemtsj", doorUtil.getTsjCount(0 + "", user));
               itemJson.put("itembxsjsj", doorUtil.getBxsjsjCount(0 + "", user));
               itemJson.put("itemdyj", doorUtil.getDyjCount(0 + "", user));
               itemJson.put("itemxsq", doorUtil.getXsqCount(0 + "", user));
               json.put("itemjson", itemJson);

               json=new JSONObject();
               json.put("name","在用设备");
               json.put("icon","llficonfont swiconzaiyong1");
               json.put("iconBg","iconBox_03");
               json.put("numberColor","#FF8184");
               json.put("lx",2);
               JSONS =new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getZy(1+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

               json=new JSONObject();
               json.put("name","借用设备");
               json.put("icon","llficonfont swiconjieyong1");
               json.put("iconBg","iconBox_04");
               json.put("numberColor","#68C56A");
               json.put("lx",3);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getJy(1+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

               json=new JSONObject();
               String bmbfl = doorUtil.getBflBySub(user.getUserSubCompany1()+"");
               //double bmbfl = doorUtil.getAllBsBflV2(user);
               json.put("name","账实不符率");
               json.put("icon","llficonfont swiconshiliangzhinengduixiang");
               json.put("iconBg","iconBox_02");
               json.put("numberColor",Double.parseDouble(bmbfl)>0.00?"red":"green");
               //json.put("numberColor",bmbfl>0.00?"red":"green");
               json.put("lx",5);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","不符率");
               subContent.put("count",Math.abs(Double.parseDouble(bmbfl))+"%");
               //subContent.put("count",Math.abs(bmbfl)+"%");
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

           }
           if("3".equals(lx)){//科室
               json=new JSONObject();
               json.put("name","科室设备");
               json.put("icon","llficonfont swicongudingzichanshebeigouzhishenqingbiao");
               json.put("iconBg","iconBox_01");
               json.put("numberColor","#4D98FF");
               json.put("lx",7);

               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getZgCount(2+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);
               //设置 item itemJson
               itemJson.put("rolesid", "ksgly");
               itemJson.put("itemtsj", doorUtil.getTsjCount(0 + "", user));
               itemJson.put("itembxsjsj", doorUtil.getBxsjsjCount(0 + "", user));
               itemJson.put("itemdyj", doorUtil.getDyjCount(0 + "", user));
               itemJson.put("itemxsq", doorUtil.getXsqCount(0 + "", user));
               json.put("itemjson", itemJson);

               json=new JSONObject();
               json.put("name","领用设备");
               json.put("icon","llficonfont swiconzaiyong1");
               json.put("iconBg","iconBox_03");
               json.put("numberColor","#FF8184");
               json.put("lx",8);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getZy(2+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

               json=new JSONObject();
               json.put("name","借用设备");
               json.put("icon","llficonfont swiconjieyong1");
               json.put("iconBg","iconBox_04");
               json.put("numberColor","#68C56A");
               json.put("lx",3);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getJy(2+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);
           }
           if("4".equals(lx)){//个人
               json=new JSONObject();
               json.put("name","在用设备");
               json.put("icon","llficonfont swicongudingzichanshebeigouzhishenqingbiao");
               json.put("iconBg","iconBox_01");
               json.put("numberColor","#4D98FF");
               json.put("lx",2);

               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getSinglezC(user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

               json=new JSONObject();
               json.put("name","领用设备");
               json.put("icon","llficonfont swiconzaiyong1");
               json.put("iconBg","iconBox_03");
               json.put("numberColor","#FF8184");
               json.put("lx",3);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getZy(3+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);

               json=new JSONObject();
               json.put("name","借用设备");
               json.put("icon","llficonfont swiconjieyong1");
               json.put("iconBg","iconBox_04");
               json.put("numberColor","#68C56A");
               json.put("lx",4);
               JSONS=new  JSONArray();
               subContent=new JSONObject();
               subContent.put("name","数量");
               subContent.put("count",doorUtil.getJy(3+"",user));
               JSONS.add(subContent);
               json.put("subContent",JSONS);
               datasMenu.add(json);
           }
           //add by 罗来福   2021-04-26
           if("5".equals(lx)){//科技处领导
               user=getRoleHrmFrist(BaseUtle.sysadmin+"");//获取  系统管理员其中的一个人 获取数据
               json = new JSONObject();
               json.put("name", "全关设备");
               json.put("icon", "llficonfont swicongudingzichanshebeigouzhishenqingbiao");
               json.put("iconBg", "iconBox_01");
               json.put("numberColor", "#4D98FF");
               json.put("lx", lx);

               JSONS = new JSONArray();
               subContent = new JSONObject();
               subContent.put("name", "总数");
               subContent.put("count", doorUtil.getZgCount(0 + "", user));
               JSONS.add(subContent);
               json.put("subContent", JSONS);
               datasMenu.add(json);
               //设置 item itemJson
               itemJson.put("rolesid", "kjcld");
               itemJson.put("itemqg", doorUtil.getZgCountWhere(0 + "", user));
               itemJson.put("itemhg", doorUtil.getHgount(0 + "", user));
               itemJson.put("itemfhg", doorUtil.getFhgount(0 + "", user));
               itemJson.put("itemzk", doorUtil.getZgCount(0 + "", user));
               itemJson.put("itemtsj", doorUtil.getTsjCount(0 + "", user));
               itemJson.put("itembxsjsj", doorUtil.getBxsjsjCount(0 + "", user));
               itemJson.put("itemdyj", doorUtil.getDyjCount(0 + "", user));
               json.put("itemjson", itemJson);

               json = new JSONObject();
               json.put("name", "在库");
               json.put("icon", "llficonfont swiconzaiku");
               json.put("iconBg", "iconBox_02");
               json.put("numberColor", "#6665FF");
               json.put("lx", 2);

               JSONS = new JSONArray();
               subContent = new JSONObject();
               subContent.put("name", "数量");
               subContent.put("count", doorUtil.getZk(0 + "", user));
               JSONS.add(subContent);
               json.put("subContent", JSONS);
               datasMenu.add(json);

               json = new JSONObject();
               json.put("name", "在用");
               json.put("icon", "llficonfont swiconzaiyong1");
               json.put("iconBg", "iconBox_03");
               json.put("numberColor", "#FF8184");
               json.put("lx", 3);
               JSONS = new JSONArray();
               subContent = new JSONObject();
               subContent.put("name", "数量");
               subContent.put("count", doorUtil.getZy(0 + "", user));
               JSONS.add(subContent);
               json.put("subContent", JSONS);
               datasMenu.add(json);

               json = new JSONObject();
               json.put("name", "借用");
               json.put("icon", "llficonfont swiconjieyong1");
               json.put("iconBg", "iconBox_04");
               json.put("numberColor", "#68C56A");
               json.put("lx", 4);
               JSONS = new JSONArray();
               subContent = new JSONObject();
               subContent.put("name", "数量");
               subContent.put("count", doorUtil.getJy(0 + "", user));
               JSONS.add(subContent);
               json.put("subContent", JSONS);
               datasMenu.add(json);
                   /*
                   json=new JSONObject();
                   json.put("name","报废中");
                   json.put("icon","llficonfont swiconbaofei");
                   json.put("iconBg","iconBox_04");
                   json.put("numberColor","#68C56A");
                   JSONS=new  JSONArray();
                   subContent=new JSONObject();
                   subContent.put("name","数量");
                   subContent.put("count",doorUtil.getBfZ(0+"",user));
                   JSONS.add(subContent);
                   json.put("subContent",JSONS);
                   datasMenu.add(json);
                   */
               json = new JSONObject();
               String bmbfl = doorUtil.getAllBsBflV2(user);
               //double bmbfl = doorUtil.getAllBsBflV2(user);
               json.put("name", "账实不符率");
               json.put("icon", "llficonfont swiconshiliangzhinengduixiang");
               json.put("iconBg", "iconBox_02");
               json.put("lx", 5);
               json.put("numberColor", Double.parseDouble(bmbfl) > 0.00 ? "red" : "green");
               //json.put("numberColor", bmbfl> 0.00 ? "red" : "green");
               JSONS = new JSONArray();
               subContent = new JSONObject();
               subContent.put("name", "不符率");
               subContent.put("count", Math.abs(Double.parseDouble(bmbfl)) + "%");
               //subContent.put("count", Math.abs(bmbfl) + "%");
               JSONS.add(subContent);
               json.put("subContent", JSONS);
               datasMenu.add(json);
           }
       }catch(Exception e){
           log.writeLog("getDoorData Exception "+e.getMessage());
           e.printStackTrace();
       }
       apidatas.put("dataArr",datasMenu);
       return apidatas;
   }

    /**
     * 获取角色中第一个用户的对象
     * @param roleid
     * @return
     */
   public User getRoleHrmFrist(String roleid){
       int userid=0;
       RecordSet re=new RecordSet();
       String sql="select a.* from hrmrolemembers a,hrmresource b  where a.roleid in ("+roleid+") and a.resourceid=b.id and b.status in (0,1,2,3)";
       re.execute(sql);
       while(re.next()){
           userid= Util.getIntValue(re.getString("resourceid"), 0);
           if(userid>0){
                break;
           }
       }
       return new User(userid);
   }
   /*
        判断  -1不存在 0：部门领导以及  1：关领导
    */
   public static int checkRole(User user){
        if(user==null){
            return -1;
        }
        int depid=user.getUserDepartment();
        int subid=user.getUserSubCompany1();
        RecordSet re1=new RecordSet();
        String sql1="select 1 from Matrixtable_3 where ','+cast(ejdwld as varchar(800))+','  like '%,"+user.getUID()+",%' ";
        log.writeLog("sql1"+sql1);
        re1.execute(sql1);
        //先判断是否是特殊分部
        if((zshgsub.equals(subid+"")||jsjsub.equals(subid)&&re1.next())){
            return 1;
        }
        //总关关领导
        RecordSet re2=new RecordSet();
        String sql2="select 1 from Matrixtable_3 where ','+cast(zggld as varchar(800))+','  like '%,"+user.getUID()+",%' ";
        log.writeLog("sql2"+sql2);
        re2.execute(sql2);
        if(re2.next()){
            return 1;
        }
        //部门领导
       RecordSet re3=new RecordSet();
       String sql3="select 1 from Matrixtable_3 where ','+cast(ejdwld as varchar(800))+','  like '%,"+user.getUID()+",%' or ','+cast(sjdwld as varchar(800))+',' like '%,"+user.getUID()+",%' ";
       log.writeLog("sql3"+sql3);
       re3.execute(sql3);
       if(re3.next()){
           return 0;
       }
       return -1;
   }

}
